package com.example.starterdemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: dengPing.xu
 * @date: 2022-04-12
 */
@Configuration
@EnableConfigurationProperties(BambooServerProperties.class)
@ConditionalOnClass(BambooServer.class)
@ConditionalOnProperty(prefix = "bamboo",value = "enabled", matchIfMissing = true)
public class BambooServiceAutoConfiguration {

    @Autowired
    private BambooServerProperties serverProperties;

    @Bean(name = "bambooServer")
    @ConditionalOnMissingBean(BambooServer.class)
    public BambooServer bambooServer(){
        BambooServer bambooServer = new BambooServer();
        bambooServer.setName(serverProperties.getName());
        return bambooServer;
    }


}
